Skip to content

fix(types): support branded primitives in evaluate arguments - #42009

Open
dgozman wants to merge 1 commit into
microsoft:mainfrom
dgozman:fix-42000
Open

fix(types): support branded primitives in evaluate arguments#42009
dgozman wants to merge 1 commit into
microsoft:mainfrom
dgozman:fix-42000

Conversation

@dgozman

@dgozman dgozman commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • NoHandles/Unboxed recurse into function return types instead of rewriting every function in the argument, so handle-free values — including branded primitives like string & { __brand } — pass through unchanged, while callbacks returning handles still get their results unboxed
  • Promises are only unwrapped in the function result position, matching the runtime behavior

Fixes #42000

Recurse into function return types in NoHandles/Unboxed instead of
rewriting every function in the argument. Functions that do not return
handles keep their original types, so arguments whose keyof includes
prototype methods, e.g. branded primitives like `string & { __brand }`,
pass through unchanged. Promises are only unwrapped in the function
result position, matching the runtime behavior.

Fixes: microsoft#42000
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

1 failed
❌ [playwright-test] › playwright.trace.spec.ts:1267 › should not nest top level expect into unfinished api calls @ubuntu-latest-node24

2 flaky ⚠️ [chromium-library] › library/beforeunload.spec.ts:130 › should support dismissing the dialog multiple times `@chromium-ubuntu-22.04-node22`
⚠️ [firefox-page] › page/page-event-request.spec.ts:181 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node20`

50736 passed, 1190 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

2 failed
❌ [chrome] › mcp/cli-core.spec.ts:364 › --raw on command without output @mcp-windows-latest-chrome
❌ [firefox] › mcp/cli-core.spec.ts:57 › click link @mcp-windows-latest-firefox

7806 passed, 1266 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

🟡 Nothing here points at this PR, but one failure I can't fully clear

Hi, I'm the Playwright bot and I took a first look at the CI failures.

This PR only touches TypeScript declarations (packages/playwright-core/types/structs.d.ts) and a type-generation test (utils/generate_types/test/test.ts) — no runtime code. Two of the three failures are proven pre-existing flakes; the third I can't reach with the diff, but I couldn't find a prior failure to call it a flake outright.

Details

Overall: the diff is types-only, so it can't change the runtime behavior of any of these tests. None look caused by this PR.

Pre-existing flake / infra

  • [chrome] › mcp/cli-core.spec.ts:364 › --raw on command without output (@mcp-windows-latest-chrome) — flake. Across the test-results DB this test failed 1 of 501 runs, passed the other 500, on SHAs unrelated to this PR.
  • [firefox] › mcp/cli-core.spec.ts:57 › click link (@mcp-windows-latest-firefox) — flake. Failed 6 of 486 runs, passed 480, on unrelated SHAs.

Uncertain

  • [playwright-test] › playwright.trace.spec.ts:1267 › should not nest top level expect into unfinished api calls (@ubuntu-latest-node24) — this test has passed 681 of 681 recorded runs and failed only here, so I can't cite a prior failure to prove it's a flake (this PR's run isn't in the aggregated DB yet). But the diff only edits .d.ts and type-gen test files, which have zero effect on the trace runtime this test exercises, so I don't see how the PR could cause it. A single un-retried failure on a rock-solid test — most likely a one-off; a rerun should confirm.

Triaged by the Playwright bot - agent run

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot and I took a first look at the CI failures here.

🟢 CI is clear — all three failures are pre-existing flakes

This PR only touches type declarations (structs.d.ts) and a generate_types test. None of the failing tests exercise the type system — they're a trace-viewer test and two MCP CLI tests — and every one of them fails on other SHAs/PRs too.

Details

Pre-existing flake / infra

The two entries the report already lists as flaky (beforeunload.spec.ts:130, page-event-request.spec.ts:181) passed on retry, so there's nothing to triage there.

I'm a first pass, not the final word — but the type-only diff and the cross-PR failure history both point the same way, so I'm confident this is noise.

Triaged by the Playwright bot - agent run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Regression]: page.evaluate() arg of a branded primitive type (string & { brand }) no longer type-checks since 1.62

2 participants